﻿using CommonType;
using MediatR;
using S_Incident.Domains.EventHandling;
using S_Incident.Domains.WorkflowEngine;
using S_Incident.Infrasturctre.DapperInterface;
using S_Incident.Read.API.Application.Commands;

namespace S_Incident.Read.API.Application.CommandsHanders
{
    public class EventDisplayCommandHanders : IRequestHandler<EventDisplayCommand, List<EventDisposition>>
    {
        private readonly IDapperEventDispositionBackfillRepository eventDisposition;
        public EventDisplayCommandHanders(IDapperEventDispositionBackfillRepository eventDisposition)
        {
            this.eventDisposition = eventDisposition;
        }
        /// <summary>
        /// 查询全部事件
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<List<EventDisposition>> Handle(EventDisplayCommand request, CancellationToken cancellationToken)
        {
            var query = $" select * from EventDisposition where EventCategory={request.eventCategory} and IsDel=0";

            return await eventDisposition.GetAllAsyncs(query);
        }
    }
}
